import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'
import './style'
import './statics/iconfont/iconfont'
import { createStore, applyMiddleware, compose } from 'redux'
import { Provider } from 'react-redux'
import thunk from 'redux-thunk'

import { combineReducers } from 'redux-immutable'

import headerReducer from './common/header/reducer'
import homeReducer from './pages/home/reducer'
import detailReducer from './pages/detail/reducer'
import loginReducer from './pages/login/reducer'

// 合并 reducer
const reducer = combineReducers({
  header: headerReducer,
  home: homeReducer,
  detail: detailReducer,
  login: loginReducer
})

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose

const enhancer = composeEnhancers(applyMiddleware(thunk))
const store = createStore(reducer, enhancer)

ReactDOM.render(
  <Provider store={store}>
    <App />
  </Provider>,
  document.getElementById('root')
)
